import 'package:flutter/material.dart';

class AppBarDemoPage extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return DefaultTabController(
        length: 2,
        child: Scaffold(
          appBar: AppBar(
            title: Text('你好Flutter'),
            backgroundColor: Colors.green,
            centerTitle: true,
            leading: IconButton(
              icon: Icon(Icons.arrow_back_ios),
              onPressed: () {
                Navigator.of(context).pop();
              },
            ),
            actions: <Widget>[
              IconButton(
                icon: Icon(Icons.search),
                onPressed: () {},
              ),
              IconButton(
                icon: Icon(Icons.settings),
                onPressed: () {},
              )
            ],
            bottom: TabBar(
              tabs: <Widget>[
                Tab(text: '热门',),
                Tab(text: '推荐',),
              ],
            ),
          ),
          body: TabBarView(
            children: <Widget>[
              ListView(
                children: <Widget>[
                  ListTile(
                    title: Text('第一个Tab'),
                  ),
                  ListTile(
                    title: Text('第一个Tab'),
                  ),
                  ListTile(
                    title: Text('第一个Tab'),
                  ),
                  ListTile(
                    title: Text('第一个Tab'),
                  ),
                  ListTile(
                    title: Text('第一个Tab'),
                  )
                ],
              ),
              ListView(
                children: <Widget>[
                  ListTile(
                    title: Text('第二个Tab'),
                  ),
                  ListTile(
                    title: Text('第二个Tab'),
                  ),
                  ListTile(
                    title: Text('第二个Tab'),
                  ),
                  ListTile(
                    title: Text('第二个Tab'),
                  ),
                  ListTile(
                    title: Text('第二个Tab'),
                  )
                ],
              )
            ],
          ),
        ));
  }
}
